package com.example.base.fragment;

import android.net.Uri;
import android.os.Bundle;

import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.base.R;
import com.example.base.adapter.Tryviewpager;
import com.google.android.material.tabs.TabLayout;

import java.util.ArrayList;
import java.util.List;


public class TryFragment extends Fragment {
  private TabLayout tabLayout;
  private ViewPager viewPager;

  private List<Fragment> fragments = new ArrayList<Fragment>();
  private List<String> titles = new ArrayList<String>();

  public TryFragment() {
    // Required empty public constructor
  }

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
  }

  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
    View inflate = inflater.inflate(R.layout.fragment_try, container, false);
    initView(inflate);
    initListener();
    return inflate;
  }

  private void initListener() {

  }

  private void initView(View inflate) {
    tabLayout = inflate.findViewById(R.id.tablayout);
    viewPager = inflate.findViewById(R.id.viewpapersys);
    fragments.add(new SystemFragment());
    fragments.add(new NavigateFragment());
    titles.add("首页");
    titles.add("体系");
    Tryviewpager tryviewpager = new Tryviewpager(getActivity().getSupportFragmentManager(), titles, fragments);
    viewPager.setAdapter(tryviewpager);
    tabLayout.setupWithViewPager(viewPager);
    tabLayout.setTabsFromPagerAdapter(tryviewpager);
  }
}